<template>
  <div style="text-align:center">
    <table style="text-align:center"
           id='programme'
           width="90%">
      <tbody>
        <tr style="height: 32px;">
          <td style="height: 32px;"
              colspan="8">
            <p style="text-align: center;font-size:32px;margin-top:20px">
              <strong>{{jkdn.jddw}}血常规体检报告单</strong>
            </p>
          </td>
        </tr>
        <tr style="height: 50px;">
          <td style="height: 50px;border-bottom:2px solid black;"
              colspan="8">
            <p>
              编号:{{jkdn.dnbh}}&nbsp;&nbsp;姓名:{{jkdn.name}}&nbsp;&nbsp;性别:{{sex==1?'男':'女'}}&nbsp;&nbsp;身份证号:{{jkdn.sfzhm}}&nbsp; &nbsp;电话:{{jkdn.lxdh}} </p>
          </td>
        </tr>
        <tr style="height: 32px;border-bottom:2px solid black;">
          <td style="height: 32px;"
              width="180">
            <p>项目名称</p>
          </td>
          <td style="height: 32px;"
              width="50">
            <p>结果</p>
          </td>
          <td style="height: 32px;"
              width="50">
            <p>单位</p>
          </td>
          <td style="height: 32px;"
              width="135">
            <p>参考范围</p>
          </td>
          <td style="height: 32px;"
              width="180">
            <p>项目名称</p>
          </td>
          <td style="height: 32px;"
              width="50">
            <p>结果</p>
          </td>
          <td style="height: 32px;"
              width="50">
            <p>单位</p>
          </td>
          <td style="height: 32px;"
              width="135">
            <p>参考范围</p>
          </td>
        </tr>
        <tr style="height: 32px;"
            v-for="d in allData"
            :key="d.id">
          <td style="height: 32px;"
              width="180">
            <p>{{d.jktjxmmc}}</p>
          </td>
          <td style="height: 32px;"
              width="50">
            <p>{{d.jktjjgsz}}</p>
          </td>
          <td style="height: 32px;"
              width="50">
            <p>{{d.jktjdw}}</p>
          </td>
          <td style="height: 32px;"
              width="135">
            <p>{{d.jktjckfw}}</p>
          </td>
          <td style="height: 32px;;border-left:1px solid black"
              width="180">
            <p>{{d.jktjxmmc1}}</p>
          </td>
          <td style="height: 32px;"
              width="50">
            <p>{{d.jktjjgsz1}}</p>
          </td>
          <td style="height: 32px;"
              width="50">
            <p>{{d.jktjdw1}}</p>
          </td>
          <td style="height: 32px;"
              width="135">
            <p>{{d.jktjckfw1}}</p>
          </td>
        </tr>
        <tr style="height: 53px;">
          <td style="height: 53px; border-top:1.5px solid black; text-align: justify;"
              colspan="8">
            <p>体检时间：{{jkdn.jdrq}}&nbsp;&nbsp; 检验人员：{{jgxx.hyry}}&nbsp;村:{{jkdn.jddw}}
              <i style="display:inline-block; padding-left: 88%; width:100%;"></i>
            </p>
          </td>
        </tr>
      </tbody>
    </table>
    <ncgctTemplate></ncgctTemplate>
  </div>
</template>
<script>
import { getObj } from '@/api/cust/health/xcgct'
import { getStore } from '@/util/store.js'
import ncgctTemplate from './ncgctTemplate'
export default {
  components: {
    ncgctTemplate
  },
  name: 'xcgct',
  data () {
    return {
      grjbxxid: '',
      jktjid: '',
      sfzh: '',
      data: [],
      jkdn: '',
      tjsj: '',
      sex: '',
      jgxx: ''
    }
  },
  created () {
    this.jgxx = getStore({ name: 'org' })
    this.jkdn = getStore({ name: 'jkdn' })
    this.sex = parseInt(this.jkdn.sfzhm.substr(16, 1)) % 2
    this.grjbxxid = this.$route.query.grjbxxid
    this.jktjid = this.$route.query.id
    this.sfzh = this.$route.query.sfzh
    this.getObj()
  },
  mounted () { },
  methods: {
    getObj () {
      getObj({
        jktjid: this.jktjid,
        grjbxxid: this.grjbxxid,
        jktjsfzh: this.sfzh
      }).then(res => {
        this.data = res.data.data
        if (!this.validatenull(this.data)) {
          // var newd = new Date(this.data[0].jktjtjsj + 'GMT+0800')
          this.tjsj = this.data[0].jktjtjsj
        }
      })
    }
  },
  computed: {
    allData () {
      var newData = this.data

      if (this.data.length > 10) {
        var arr = this.data.slice(10, this.data.length)
        newData = this.data.slice(0, 10)
        var temp = 10
        if (arr.length < 10) {
          temp = arr.length
        }

        for (var i = 0; i < temp; i++) {
          newData[i].jktjxmmc1 = arr[i].jktjxmmc
          newData[i].jktjjgsz1 = arr[i].jktjjgsz
          newData[i].jktjdw1 = arr[i].jktjdw
          newData[i].jktjckfw1 = arr[i].jktjckfw
        }
      }
      return newData
    }
  },
  props: []
}
</script>